//
//  MBProgressHUD+Conveniently.m
//  app
//
//  Created by 刘华舟 on 15/5/7.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "MBProgressHUD+Conveniently.h"



@implementation MBProgressHUD (Conveniently)

//全屏显示菊花
+ (void)showMBProgressHUBOnWindowsWithMessage:(NSString *)message{
    MBProgressHUD *windowsHUB = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
    windowsHUB.labelText = message;
}
//隐藏全屏菊花
+ (void)dismissMBProgressHUBOnWindows{
    [MBProgressHUD hideHUDForView:[UIApplication sharedApplication].keyWindow animated:YES];
}


+ (void)showToastWithMessage:(NSString *)message offset:(CGPoint)offset{
    MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:[UIApplication sharedApplication].keyWindow];
    [[UIApplication sharedApplication].keyWindow addSubview:HUD];
    HUD.labelText = message;
    HUD.mode = MBProgressHUDModeText;
    
    //指定距离中心点的X轴和Y轴的偏移量，如果不指定则在屏幕中间显示
    HUD.yOffset = offset.y;
    HUD.xOffset = offset.x;
    
    [HUD showAnimated:YES whileExecutingBlock:^{
        sleep(2);
    } completionBlock:^{
        [HUD removeFromSuperview];
    }];
}

//toast提示指定view
+ (void)showToastWithMessage:(NSString *)message toView:(UIView *)view{
    MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:view];
    [view addSubview:HUD];
    HUD.labelText = message;
    HUD.mode = MBProgressHUDModeText;
    
    //指定距离中心点的X轴和Y轴的偏移量，如果不指定则在屏幕中间显示
//    HUD.yOffset = 0;
//    HUD.xOffset = 0;
    
    [HUD showAnimated:YES whileExecutingBlock:^{
        sleep(2);
    } completionBlock:^{
        [HUD removeFromSuperview];
    }];
}

@end
